from google.appengine.ext import db
import model, logging
from google.appengine.api import memcache

def get_fields(table_name):
    mkey = '%s-fields' % table_name
    logging.info('getting schema for table: %s' % table_name)
    if memcache.get(mkey):
        return memcache.get(mkey)
    q = model.dlz_table_schema.gql("where table_name = :1 order by field_position asc", table_name)
    fields = model.process_query(q)
    memcache.set(mkey, fields)
    logging.info(fields)
    return fields
    
        
    